package 卡片1443;

import java.util.Arrays;
import java.util.Iterator;

public class Main {
	public static void main(String[] args) {
		int[] arr=new int[10];
		Arrays.fill(arr, 2021);
		int num=1;
		while(true) {
			int sum=num;
			while(sum>0) {
				int tmp=sum%10;
				if(arr[tmp]==0) {
					System.out.println(num-1);
					return;
				}
				arr[tmp]--;
				sum/=10;
			}
			num++;
		}
	}
}
